#include <iostream>
#include <string>
#include <vector>
using namespace std;

int isS(string s1,string s2){
    vector<vector<int> >dp(s1.size() + 1,vector<int>(s2.size() + 1, 0));
    dp[0][0] = 1;
    for(int i = 1;i < s1.size();i++){
        for(int j = 1;j < s2.size();j++){
            if(s1[i] == s2[j]){
                dp[i][j] = dp[i - 1][j - 1];
                
            }else if(s1[i] == '?'){
                dp[i][j] = dp[i - 1][j - 1];
                
            }else if(s1[i] == '*'){
                dp[i][j] = dp[i - 1][j] || dp[i - 1][j - 1] || dp[i][j - 1];
            }else{
                dp[i][j] = 0;
                
            }
        }
    }
    return dp[s1.size() - 1][s2.size() - 1];
}

int main(){
    string s1,s2;
    getline(cin,s1);
    getline(cin,s2);
    int res = isS(s1,s2);
	if(res == 1) cout<<"true"<<endl;
    else cout<<"false"<<endl;
    return 0;
}
